package cn.edu.flink.tutorial.transform;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Collections;

/*
DataStream#split() 操作在几个版本中被标记为 deprecated 后被删除。请使用 Side Outputs) 来替代.
 */
public class Split {
//    public static void main(String[] args) throws Exception {
//        // 创建执行环境
//        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
//
//        // 从文件中读取数据
//        String inputPath = "hello.txt";
//        DataStreamSource<String> streamSource = env.readTextFile(inputPath);
//
//        streamSource.
//        SplitStream<String> splitOutput = streamSource.split(
//                new OutputSelector<String>() {
//                    @Override
//                    public Iterable<String> select(String s) {
//                        if (s.contains(" ")) return Collections.singletonList("2");
//                        return Collections.singletonList("1");
//                    }
//                }
//        );
//
//        DataStream<String> selectedOutput1 = splitOutput.select("1");
//        DataStream<String> selectedOutput2 = splitOutput.select("2");
//
//        selectedOutput1.print();
//        env.execute();
//    }
}
